Skip to content

Conversation

@kekaczma
Copy link
Contributor

@kekaczma kekaczma commented Dec 29, 2025

SYCL kernel names are generated during template instantiation using MangleContext, which produces different encodings based on target ABI. When host compilation uses Microsoft ABI and device compilation targets Itanium ABI (CUDA/HIP), this caused runtime kernel lookup failures:

No kernel named _ZTSZZ21performIncrementationENK... was found

The issue occurred because Sema::PerformPendingInstantiations() used ASTContext::createMangleContext(), which creates an ABI-specific context for the primary target. In cross-ABI scenarios (Microsoft host + Itanium device), this produced inconsistent names between host and device.

Solution:

  • Added createSYCLMangleContext() helper that detects Microsoft-to-Itanium ABI scenarios
  • When detected, uses createDeviceMangleContext() for host compilation to ensure Itanium mangling on both sides
  • Applied to both host and device compilation phases via (LangOpts.SYCLIsHost || LangOpts.SYCLIsDevice) guard

This ensures identical kernel names across compilations, allowing runtime lookup to succeed.

@kekaczma kekaczma requested review from a team as code owners December 29, 2025 14:46
@kekaczma kekaczma requested a review from slawekptak December 29, 2025 14:46
@kekaczma kekaczma marked this pull request as draft December 30, 2025 09:59
@kekaczma kekaczma force-pushed the CMPLRLLVM-69642-sycl-cuda-kernel-mangling branch from 32c9f70 to 55c155c Compare December 30, 2025 10:35
@kekaczma kekaczma force-pushed the CMPLRLLVM-69642-sycl-cuda-kernel-mangling branch from 55c155c to 307759c Compare December 30, 2025 11:42
@kekaczma kekaczma force-pushed the CMPLRLLVM-69642-sycl-cuda-kernel-mangling branch from 451b21b to 7445a0a Compare December 30, 2025 12:44
@kekaczma kekaczma force-pushed the CMPLRLLVM-69642-sycl-cuda-kernel-mangling branch from 520457d to ede11a7 Compare January 13, 2026 16:57
In SYCL offload compilation, when the host uses Microsoft ABI and the
device uses Itanium ABI (e.g., Windows host with CUDA device), kernel
names were mangled differently between host and device code, causing
runtime errors when the host tried to find kernels by name.

This fix ensures consistent mangling by using the device's mangling
context on the host side when compiling for cross-ABI scenarios. This
is detected by checking if the host target uses Microsoft ABI while
the auxiliary (device) target uses Itanium ABI.

The change is minimal and only affects the specific cross-ABI case,
preserving existing behavior for same-ABI compilations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants